import { AutoTaskCfgBase } from "./Sheets"
import { SheetManager } from "../../ccc3-framework-core/framework/modules/sheetManager";
export class AutoTaskCfg extends AutoTaskCfgBase {
  //id索引
  public static get(id: any) {
    if ((this as any)[id]) return (this as any)[id];
    return SheetManager.get("AutoTaskCfg", id, AutoTaskCfg);
  }
  public static getAll(): AutoTaskCfg[] {
    return SheetManager.getAllSheets("AutoTaskCfg", AutoTaskCfg);
  }

  public static getAutoTaskCfgByMapId(mapId: number): AutoTaskCfg[] {
    return this.getAll().filter(item => item.mapId == mapId);
  }

  public static getAutoTaskCfgTotalWeight(cfgArr: AutoTaskCfg[]): number {
    let totalWeight = 0;
    cfgArr.forEach(item => {
      totalWeight += item.weight;
    });
    return totalWeight;
  }
}